﻿// =================================================================== 
// 业务逻辑层(GDIT.BLL)
//====================================================================
// 文件：BVideoInformationArticle.cs
// 项目名称：学院网站
// 创建时间：2012-08-12
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：视频资讯操作逻辑
// ===================================================================
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using GDIT.Base.LogHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDIT.Model;

namespace GDIT.BLL
{
    public class BVideoInformationArticle
    {
        private Pattern.DALAbstractFactory dataFactory = DataProvider.defaultProvider;

        /// <summary>
        /// 管理员展示页面
        /// </summary>
        /// <returns></returns>
        public XPCollection SelectAllVideoyAdmin()
        {
            return dataFactory.DALVideoInformationArticleProvider.SelectAllVideoyAdmin();
        }

        /// <summary>
        /// 新增加一篇视频资讯
        /// </summary>
        /// <param name="bulletin">需要增加的视频资讯对象</param>
        /// <returns>1：新增成功  0：新增失败</returns>
        public bool InsertVideoInformationArticle(Mtb_VideoInformationArticle bulletin)
        {
            Logger.Info(String.Format("视频资讯文章的名称[{0}]", bulletin.VideoName));
            int result = dataFactory.DALVideoInformationArticleProvider.InsertVideoInformationArticle(bulletin);
            if (result == 1)
            {
                Logger.Info("Insert success");
                return true;
            }
            else
            {
                Logger.Info("Insert false");
                return false;
            }
        }

        /// <summary>
        /// 删除一篇视频资讯
        /// </summary>
        /// <param name="bulletin">需要删除的视频资讯对象</param>
        /// <returns>1：新增成功  0：新增失败</returns>
        public bool DeleteVideoInformationArticle(int id)
        {
            Logger.Info(String.Format("视频资讯文章的ID[{0}]", id));
            int result = dataFactory.DALVideoInformationArticleProvider.DeleteVideoInformationArticle(id);
            if (result == 1)
            {
                Logger.Info("Delete success");
                return true;
            }
            else
            {
                Logger.Info("Delete false");
                return false;
            }
        }

        /// <summary>
        /// 更新一篇视频资讯
        /// </summary>
        /// <param name="bulletin">需要更新的视频资讯的对象</param>
        /// <returns>1：新增成功  0：新增失败</returns>
        public bool UpdateVideoInformationArticle(Mtb_VideoInformationArticle bulletin)
        {
            Logger.Info(String.Format("视频资讯文章的名称[{0}]", bulletin.VideoName));
            int result = dataFactory.DALVideoInformationArticleProvider.UpdateVideoInformationArticle(bulletin);
            if (result == 1)
            {
                Logger.Info("Update success");
                return true;
            }
            else
            {
                Logger.Info("Update false");
                return false;
            }
        }

        /// <summary>
        /// 查询所有非置顶，重点的公告列表
        /// </summary>
        /// <returns>返回所有的视频资讯列表</returns>
        public XPCollection SelectAllVideoInformationArticle()
        {
            return dataFactory.DALVideoInformationArticleProvider.SelectAllVideoInformationArticle();
        }

        /// <summary>
        /// 根据公告Id查询并返回视频资讯单一记录
        /// </summary>
        /// <param name="id">需要查询的视频资讯Id</param>
        /// <returns>返回公告单一记录</returns>
        public Mtb_VideoInformationArticle SelectVideoInformationArticleById(int id)
        {
            return dataFactory.DALVideoInformationArticleProvider.SelectVideoInformationArticleById(id);
        }

        /// <summary>
        /// 显示置顶视频资讯
        /// </summary>
        /// <returns>返回置顶视频资讯列表</returns>
        public XPCollection SelectVideoInformationArticleByTop()
        {
            return dataFactory.DALVideoInformationArticleProvider.SelectVideoInformationArticleByTop();
        }

        /// <summary>
        /// 显示重点视频资讯
        /// </summary>
        /// <returns>返回重点视频资讯列表</returns>
        public XPCollection SelectVideoInformationArticleByImportant()
        {
            return dataFactory.DALVideoInformationArticleProvider.SelectVideoInformationArticleByImportant();
        }

        /// <summary>
        /// 显示首页的视频资讯内容
        /// </summary>
        /// <returns></returns>
        public XPCollection SelectVideoInformationArticleByTopAndImportant()
        {
            return dataFactory.DALVideoInformationArticleProvider.SelectVideoInformationArticleByTopAndImportant();
        }

        /// <summary>
        /// 设置公告为重点显示
        /// </summary>
        /// <returns>1：更新成功  0：更新失败</returns>
        public bool UpdateBulletinArticleByImportant(Mtb_VideoInformationArticle bulletin)
        {
            Logger.Info(String.Format("视频资讯文章的名称[{0}]", bulletin.VideoName));
            int result = dataFactory.DALVideoInformationArticleProvider.UpdateBulletinArticleByImportant(bulletin);
            if (result == 1)
            {
                Logger.Info("Update success");
                return true;
            }
            else
            {
                Logger.Info("Update false");
                return false;
            }
        }

        /// <summary>
        /// 设置公告为置顶显示
        /// </summary>
        /// <returns>1：更新成功  0：更新失败</returns>
        public bool UpdateBulletinArticleByTop(Mtb_VideoInformationArticle bulletin)
        {
            Logger.Info(String.Format("视频资讯文章的名称[{0}]", bulletin.VideoName));
            int result = dataFactory.DALVideoInformationArticleProvider.UpdateBulletinArticleByTop(bulletin);
            if (result == 1)
            {
                Logger.Info("Update success");
                return true;
            }
            else
            {
                Logger.Info("Update false");
                return false;
            }
        }
    }
}
